package cn.maxhou.sl1.config;

import cn.maxhou.sl1.entity.SysUser;
import cn.maxhou.sl6.config.JavaConfig;
import cn.maxhou.sl7.MainApplication;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

class JavaConfigTest3 {
    private static  final Logger LOGGER = LoggerFactory.getLogger(JavaConfigTest3.class);
    @Test
    public void testJavaConfig() {
        //由于JavaConfig是基于注解进行配置
        //所以我们需要创建的是AnnotationConfigApplicationContext对象
        ApplicationContext context = new AnnotationConfigApplicationContext(MainApplication.class);
        //获取bean对象
        SysUser user = (SysUser) context.getBean("user");
        LOGGER.debug("user.getRealName（)={}", user.getRealName());
        LOGGER.debug("user.getAccount()={}", user.getAccount());
        LOGGER.debug("user.getPassword()={}", user.getPassword());
        LOGGER.debug("user.getSex()={}", user.getSex());
    }
}